import request from "@/utils/request";

enum API {
  // 用户
  login = "/login",
  login_out = "/login_out",
  manage_video_list = "/manage_video_list",
  add_video_info = "/add_video_info",
  video_index = "/video_index",
  update_video_info = "/update_video",
  video_list = "/video_list",
  get_video = "/get_video",
  video_detail = "/video_detail",
  send_code = "/send_code",
  regist_user = "/regist_user",
  user = "/user",
  news_list = "/news_list",
  news_detail = "/news_detail",
  window_list = "/window_list",
  change_password = "/change_password",
  change_my_password = "/change_my_password",
  change_name_img="/change_name_img",
  use_exchange_code="/use_exchange_code",
  exchange_code_list="/exchange_code_list",
  build_exchange_code="/build_exchange_code",
  update_exchange_code="/update_exchange_code",
  phone_login="/phone_login"
}

// 使用手机号和验证码登录
export const phone_login = (data) => request.post(API.phone_login, data);

// 更新（未使用）兑换码的信息
export const update_exchange_code = (data) => request.put(API.update_exchange_code, data);

// 生成一个会员兑换码
export const build_exchange_code = (data) => request.get(API.build_exchange_code, data);

// 兑换码列表
export const exchange_code_list = (data) => request.get(API.exchange_code_list, data);

// 第三方用户（已登录）使用兑换码
export const use_exchange_code = (data) => request.post(API.use_exchange_code, data);

// 修改头像和用户名
export const change_name_img = (data) => request.post(API.change_name_img, data);

// 修改我的密码
export const change_my_password = (data) => request.post(API.change_my_password, data);

// 忘记密码
export const change_password = (data) => request.post(API.change_password, data);

// 热门课程
export const window_list = (params) => request.get(API.window_list, { params });

// 新闻列表
export const news_detail = (params) => request.get(API.news_detail, { params });

// 新闻列表
export const news_list = (params) => request.get(API.news_list, { params });

// 用户账户信息
export const user = (params) => request.get(API.user, { params });

// 账号密码式登录
export const regist_user = (data) => request.post(API.regist_user, data);

// 验证码
export const send_code = (params) => request.get(API.send_code, { params });

// 视频详情信息
export const video_detail = (params) =>
  request.get(API.video_detail, { params });

// 获取视频文件
export const get_video = (params) => request.get(API.get_video, { params });

// 管理视频列表
export const video_list = (params) => request.get(API.video_list, { params });

// 账号密码式登录
export const update_video_info = (data) =>
  request.put(API.update_video_info, data);

// 账号密码式登录
export const login = (data) => request.post(API.login, data);

// 登出
export const login_out = () => request.get(API.login_out);

// 管理视频列表
export const manage_video_list = (params) =>
  request.get(API.manage_video_list, { params });

// 新增视频信息
export const add_video_info = (data) => request.post(API.add_video_info, data);

// 查询索引
export const video_index = () => request.get(API.video_index);
